// Quicks.cpp : main source file for Quicks.exe
//

#include "stdafx.h"

#include "resource.h"

#include "QuicksView.h"
#include "MainFrm.h"
#include "AlphaBlend.h"


CAppModule _Module;


int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT, HINSTANCE hInstance = NULL)
{
	CMessageLoop theLoop;
	_Module.AddMessageLoop(&theLoop);

	RECT rScreen;
	BOOL bRes = SystemParametersInfo(SPI_GETWORKAREA, NULL, &rScreen, NULL);


	/*
	Retrieves the size of the work area on the primary display monitor. 
	The work area is the portion of the screen not obscured by the system 
	taskbar or by application desktop toolbars. The pvParam parameter must 
	point to a RECT structure that receives the coordinates of the work area, 
	expressed in virtual screen coordinates.

	To get the work area of a monitor other than the primary display monitor, call the GetMonitorInfo function.
	*/
	RECT r;
	r.left = rScreen.left;
	r.right = rScreen.right;
	r.top = rScreen.bottom - 20;
	r.bottom = rScreen.bottom;
	CMainFrame wndMain(hInstance);
	if(wndMain.CreateEx(NULL, r, WS_POPUP|WS_VISIBLE, WS_EX_TOOLWINDOW) == NULL)
	{
		ATLTRACE(_T("Main window creation failed!\n"));
		return 0;
	}
	// transparency?
	CAlphaBlend ab(wndMain);
	ab.SetTransparent();

	wndMain.ShowWindow(nCmdShow);

	int nRet = theLoop.Run();

	_Module.RemoveMessageLoop();
	return nRet;
}

int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
	HRESULT hRes = ::CoInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to 
// make the EXE free threaded. This means that calls come in on a random RPC thread.
//	HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
	ATLASSERT(SUCCEEDED(hRes));

	// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
	::DefWindowProc(NULL, 0, 0, 0L);

	AtlInitCommonControls(ICC_BAR_CLASSES);	// add flags to support other controls

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	int nRet = Run(lpstrCmdLine, nCmdShow, hInstance);

	_Module.Term();
	::CoUninitialize();

	return nRet;
}
